Next: The Units Table, Previous: Units, Up: Units [Contents][Index]
A units expression is a formula which is basically a number multiplied and/or divided by one or more unit names, which may optionally be raised to integer powers. Actually, the value part need not be a number; any product or quotient involving unit names is a units expression. Many of the units commands will also accept any formula, where the command applies to all units expressions which appear in the formula.
A unit name is a variable whose name appears in the unit table, or a variable whose name is a prefix character like ‘k’ (for “kilo”) or ‘u’ (for “micro”) followed by a name in the unit table. A substantial table of built-in units is provided with Calc; see Predefined Units. You can also define your own unit names; see User-Defined Units.
Note that if the value part of a units expression is exactly ‘1’, it will be removed by the Calculator’s automatic algebra routines: The formula ‘1 mm’ is “simplified” to ‘mm’. This is only a display anomaly, however; ‘mm’ will work just fine as a representation of one millimeter.
You may find that Algebraic mode (see Algebraic Entry) makes working with units expressions easier. Otherwise, you will have to remember to hit the apostrophe key every time you wish to enter units.
The u s (calc-simplify-units)
[usimplify] command simplifies a units expression.
It uses Calc’s algebraic simplifications to simplify the
expression first as a regular algebraic formula; it then looks
for features that can be further simplified by converting one
object’s units to be compatible with another’s. For
example, ‘5 m + 23 mm’ will simplify to
‘5.023 m’. When different but compatible
units are added, the righthand term’s units are converted
to match those of the lefthand term. See Simplification
Modes, for a way to have this done automatically at all
times.
Units simplification also handles quotients of two units with
the same dimensionality, as in
‘2 in s/L cm’
to ‘5.08 s/L’; fractional powers of
unit expressions, as in ‘sqrt(9 mm^2)’
to ‘3 mm’ and ‘sqrt(9
acre)’ to a quantity in meters; and
floor, ceil, round,
rounde, roundu, trunc,
float, frac, abs, and
clean applied to units expressions, in which case
the operation in question is applied only to the numeric part of
the expression. Finally, trigonometric functions of quantities
with units of angle are evaluated, regardless of the current
angular mode.
The u c (calc-convert-units) command
converts a units expression to new, compatible units. For
example, given the units expression ‘55
mph’, typing u c m/s RET produces ‘24.5872
m/s’. If you have previously converted a units
expression with the same type of units (in this case, distance
over time), you will be offered the previous choice of new units
as a default. Continuing the above example, entering the units
expression ‘100 km/hr’ and typing u
c RET (without specifying new
units) produces ‘27.7777777778
m/s’.
The u c command treats temperature units (like
‘degC’ and ‘K’)
as relative temperatures. For example, u c converts
‘10 degC’ to ‘18
degF’: A change of 10 degrees Celsius corresponds to
a change of 18 degrees Fahrenheit. To convert absolute
temperatures, you can use the u t
(calc-convert-temperature) command. The value on the
stack must be a simple units expression with units of temperature
only. This command would convert ‘10
degC’ to ‘50 degF’, the
equivalent temperature on the Fahrenheit scale.
While many of Calc’s conversion factors are exact, some are necessarily approximate. If Calc is in fraction mode (see Fraction Mode), then unit conversions will try to give exact, rational conversions, but it isn’t always possible. Given ‘55 mph’ in fraction mode, typing u c m/s RET produces ‘15367:625 m/s’, for example, while typing u c au/yr RET produces ‘5.18665819999e-3 au/yr’.
If the units you request are inconsistent with the original units, the number will be converted into your units times whatever “remainder” units are left over. For example, converting ‘55 mph’ into acres produces ‘6.08e-3 acre / (m s)’. Remainder units are expressed in terms of “fundamental” units like ‘m’ and ‘s’, regardless of the input units.
If you intend that your new units be consistent with the
original units, the u n
(calc-convert-exact-units) command will check the
units before the conversion. For example, to change
‘mi/hr’ to
‘km/hr’, you could type u c km
RET, but u n km RET would signal an error. You would need to
type u n km/hr RET.
One special exception is that if you specify a single unit name, and a compatible unit appears somewhere in the units expression, then that compatible unit will be converted to the new unit and the remaining units in the expression will be left alone. For example, given the input ‘980 cm/s^2’, the command u c ms will change the ‘s’ to ‘ms’ to get ‘9.8e-4 cm/ms^2’. The “remainder unit” ‘cm’ is left alone rather than being changed to the base unit ‘m’.
You can use explicit unit conversion instead of the u s command to gain more control over the units of the result of an expression. For example, given ‘5 m + 23 mm’, you can type u c m or u c mm to express the result in either meters or millimeters. (For that matter, you could type u c fath to express the result in fathoms, if you preferred!)
In place of a specific set of units, you can also enter one of
the units system names si, mks
(equivalent), or cgs. For example, u c si
RET converts the expression into
International System of Units (SI) base units. Also, u c
base converts to Calc’s base units, which are the
same as si units except that base uses
‘g’ as the fundamental unit of mass
whereas si uses
‘kg’.
The u c command also accepts composite
units, which are expressed as the sum of several compatible
unit names. For example, converting ‘30.5
in’ to units ‘mi+ft+in’
(miles, feet, and inches) produces ‘2 ft + 6.5
in’. Calc first sorts the unit names into order of
decreasing relative size. It then accounts for as much of the
input quantity as it can using an integer number times the
largest unit, then moves on to the next smaller unit, and so on.
Only the smallest unit may have a non-integer amount attached in
the result. A few standard unit names exist for common
combinations, such as mfi for
‘mi+ft+in’, and tpo for
‘ton+lb+oz’. Composite units are
expanded as if by a x, so that
‘(ft+in)/hr’ is first converted to
‘ft/hr+in/hr’.
If the value on the stack does not contain any units, u c will prompt first for the old units which this value should be considered to have, then for the new units. (If the value on the stack can be simplified so that it doesn’t contain any units, like ‘ft/in’ can be simplified to 12, then u c will still prompt for both old units and new units. Assuming the old and new units you give are consistent with each other, the result also will not contain any units. For example, u c cm RET in RET converts the number 2 on the stack to 5.08.
The u b (calc-base-units) command is
shorthand for u c base; it converts the units
expression on the top of the stack into base units.
If u s does not simplify a units expression as far as
you would like, try u b.
Like the u c command, the u b command treats temperature units as relative temperatures.
The u r (calc-remove-units) command
removes units from the formula at the top of the stack. The
u x (calc-extract-units) command extracts
only the units portion of a formula. These commands essentially
replace every term of the formula that does or doesn’t
(respectively) look like a unit name by the constant 1, then
resimplify the formula.
The u a (calc-autorange-units) command
turns on and off a mode in which unit prefixes like
k (“kilo”) are automatically applied to
keep the numeric part of a units expression in a reasonable
range. This mode affects u s and all units conversion
commands except u b. For example, with autoranging on,
‘12345 Hz’ will be simplified to
‘12.345 kHz’. Autoranging is useful for
some kinds of units (like Hz and m),
but is probably undesirable for non-metric units like
ft and tbsp. (Composite units are more
appropriate for those; see above.)
Autoranging always applies the prefix to the leftmost unit
name. Calc chooses the largest prefix that causes the number to
be greater than or equal to 1.0. Thus an increasing sequence of
adjusted times would be ‘1 ms, 10 ms, 100 ms, 1 s, 10
s, 100 s, 1 ks’. Generally the rule of thumb is that
the number will be adjusted to be in the interval ‘[1
.. 1000)’, although there are several exceptions to
this rule. First, if the unit has a power then this is not
possible; ‘0.1 s^2’ simplifies to
‘100000 ms^2’. Second, the
“centi-” prefix is allowed to form cm
(centimeters), but will not apply to other units. The
“deci-,” “deka-,” and
“hecto-” prefixes are never used. Thus the allowable
interval is ‘[1 .. 10)’ for millimeters
and ‘[1 .. 100)’ for centimeters.
Finally, a prefix will not be added to a unit if the resulting
name is also the actual name of another unit; ‘1e-15
t’ would normally be considered a
“femto-ton,” but it is written as ‘1000
at’ (1000 atto-tons) instead because ft
would be confused with feet.
Next: The Units Table, Previous: Units, Up: Units [Contents][Index]